package com.jt.controller;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.PropertySource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController //想前端返回json 特殊格式的字符串
@PropertySource(value ="classpath:/properties/hello.properties",encoding = "utf-8")
public class HelloController {
    //从容器中获取属性数据 springel表达式(spel)
    @Value("${hello.msg}")  //自动生产get/set方法
    private String msg;  //YML获取数据

    @Value("${jt.msg}")
    private String msg2;  //properties 文件获取数据



    //如果返回值为string类型,则按照原始格式返回
    @GetMapping("/hello")
    public String hello(){
        return msg+"|"+msg2;
    }
}
